<?php
define('DEV_IMAGES_CACHE_DIR', '/cache/images/');
define('DEV_ICON_NO_FILE', '/public/styles/images/nofile.png');
require_once('library/Helpers/ImageUtils.php');
	if(isset($_GET['filename'])){
		
		$filename = $_GET['filename'];
		$filepath = $_GET['filepath'];
		
		$w = $_GET['width'];
		$h = $_GET['height'];
		
		$ext = $_GET['ext'];
		if (isset($_GET['method']) && $_GET['method'] != ''){
			$method = $_GET['method'];
		} else {
			$method = 'zc';
		}
		$im = imagecreatetruecolor($w, $h);
		$image = ImageThumb::createThumb($filename, $ext, $filepath, $w, $h, $method);
		
		switch(strtolower($ext))
		{
			case 'png' :
				{
					imagecopyresampled($im, imagecreatefrompng(substr($image,1,strlen($image))), 0, 0, 0, 0, $w, $h, $w, $h);
				}
			break;
			
			case 'gif' :
				{
					imagecopyresampled($im, imagecreatefromgif(substr($image,1,strlen($image))), 0, 0, 0, 0, $w, $h, $w, $h);
				}
			break;
			
			case 'jpeg':
				{
					imagecopyresampled($im, imagecreatefromjpeg(substr($image,1,strlen($image))), 0, 0, 0, 0, $w, $h, $w, $h);
				}
			break;
			
			case 'jpg':
				{
					imagecopyresampled($im, imagecreatefromjpeg(substr($image,1,strlen($image))), 0, 0, 0, 0, $w, $h, $w, $h);
				}
			break;
		}
		
		
		imagecopymerge($im, $im, $w, $h ,100,100,$w,$h,100);
		
		header('Content-type: image/png');
		imagepng($im);
		imagedestroy($im);
		exit();
	}

?>